#

| Chapter 3 Understanding Regular Expression Syntax |

## 3.3 I Never Metacharacter I Didn't Like

Table 3.4 lists interesting examples of regular expressions, many of which have been described in this chapter.

Table 3.4: Useful Regular Expressions
Item | Regular Expression
--- | ---
Postal Abbreviation for State | [A-Z][A-Z]
City, State | ^.*,[A-Z][A-Z]
City, State, Zip (POSIX `egrep`) | ^.*,[A-Z][A-Z][0-9]{5}(-[0-9]{4})?
Month, Day, Year | [A-Z][a-z]\{3,9\}[0-9]\{1,2\},[0-9]\{4\}
U.S. Social Security Number | [0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\}
North-American Local Telephone | [0-9]\{3\}-[0-9]\{4\}
Formatted Dollar Amounts | \$[0-9]*\.[0-9][0-9]
`troff` In-line Font Requests | \\f[(BIRP]C*[BW]*
`troff` Requests | ^\.[a-z]\{2\}
`troff` Macros | ^\.[A-Z12].
`troff` Macro with arguments | ^\.[A-Z12].".*"
HTML In-line Codes | <[^>]*>
Ventura Publisher Style Codes | ^@.*=.*
Match blank lines | ^$
Match entire line | ^.*$
Match one or more spaces | *

3.2 A Line-Up of Characters |  | 4. Writing sed Scripts